<?php
declare (strict_types=1);

namespace app\controller\v1;

use app\model\Goods as GoodsM;
use app\model\GoodsMatchParam;
use app\serviceapp\CategoryService;
use app\serviceapp\UserFavoriteService;
use think\Request;
use think\annotation\route\Group;
use think\annotation\Route;
use app\serviceapp\GoodsService;
use app\middleware\ApiSignCheck;
use think\annotation\route\Middleware;

/**
 * Goods
 * Class Goods
 * @package app\controller\v1
 * @Group("v1/goods")
 */
class Goods extends Base
{

    /**
     * 根据跟踪码获取商品信息
     * @Route("info", method="GET")
     */
    public function info()
    {
        $trackingCode = input('trackingCode', '', 'string');
        if (empty($trackingCode)) {
            return json_error(10002);
        }

        $tradeCode = base64_decode($trackingCode);
        $tradeCodeArr = explode(':', $tradeCode);
        $goodsId = $tradeCodeArr[1];
        $goodsM = new GoodsM();
        $goodsInfo = $goodsM->where('goods_id', $goodsId)->field(['goods_id','provider_id','supplier_id','goods_type','goods_pic','goods_title'])->find();
        return json_ok($goodsInfo,200);
    }

}
